<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>File upload</title>
<script type="text/javascript" src="jQuery.js"></script>
</head>
<body>
<div id="uploadForm">
         <img src='1.jpg' alt='' id='img' style="width: 100px;height: 100px;top: 20px;"/><br>
<input id="file" type="file"/>
<button id="upload" type="button" onclick="getUpload()">upload</button>
</div>
<script type="text/javascript">
        function getUpload(){
        var formData = new FormData();
        formData.append('file', $('#file')[0].files[0]);
        $.ajax({
        url: 'http://localhost:8080/Tourism/file/fileupfile.do',
        type: 'POST',
        dataType:"json",
        cache: false,
        data: formData,
        processData: false,
        contentType: false
        }).done(function(res) {
        alert(res.data);
        document.getElementById("img").src = res.data;
        }).fail(function(res) {
        alert("fail");
        });
        }
</script>
</body>
</html>